<?php

/*
 * Action 4$
 *
 * +1 Card
 * +1 Action 
 * Reveal the top card of your deck; you may discard it. Either way, if it is an... Action card, +1 Action, Treasure card, +1 Coin, Victory card, +1 Card
 */

class Ironmonger extends Card implements iAction, iKingdom, iDarkAges {

    public function __construct() {
        parent::__construct("Ironmonger", 4);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Card",
            "+1 Action",
            "Reveal the top card of your deck; you may discard it. Either way, if it is an... Action card, +1 Action, Treasure card, +1 Coin, Victory card, +1 Card");
    }

    public function play(Game $game, $isRealCard) {
        $drawed_cards = $game->drawCards(1);
        $game->addActions(1);
        ScreenDisplay::addScreenMessage($game, true, "get +1 action  and draw " . nicePrint($drawed_cards), "gets +1 action and draws " . sizeof($drawed_cards) . " cards");

        $card = $game->peekCardFromDrawDeck();
        if ($card) {
            ScreenDisplay::addScreenMessage($game, true, "reveal " . nicePrint($card), "reveals " . ScreenDisplay::$LMSG);

            $options = array(new Option(1, "Yes"), new Option(2, "No"));
            $output = MySocket::GetUserReply($game, Input_ChooseOne, $options, 1, 1, null, "Discard " . $card->getValue() . "?");
            $answer = $output[0];
            if ($answer == "Yes") {
                $game->discardCardsFromDrawDeck(1);
                ScreenDisplay::addScreenMessage($game, false, ", discard it ", ", discards it ");
            } else {
                ScreenDisplay::addScreenMessage($game, false, ", leave it on top of your deck", ", leaves it on top of his deck");
            }

            if ($card instanceof iAction) {
                $game->addActions(1);
                ScreenDisplay::addScreenMessage($game, false, " and get +1 action", " and gets +1 action");
            }

            if ($card instanceof iTreasure) {
                $game->addMoney(new Price(1));
                ScreenDisplay::addScreenMessage($game, false, " and get +1$", " and gets +1$");
            }

            if ($card instanceof iVictory) {
                $drawed_cards = $game->drawCards(1);
                ScreenDisplay::addScreenMessage($game, false, " and draw " . nicePrint($drawed_cards), " and draws " . sizeof($drawed_cards) . " cards");
            }
        }
        else {
            ScreenDisplay::addScreenMessage($game, true, "draw nothing ", "draws nothing");
        }

        $game->cardActionFinished();
        return true;
    }

}

?>